package com.nf.health.app.inquiry.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.nf.health.app.R;
import com.nf.health.app.inquiry.bean.DoctorDetailBean;
import com.nf.health.app.inquiry.bean.SubsDirect;
import com.nf.health.app.inquiry.impl.bindviewhl.DocType;
import com.nf.health.app.inquiry.impl.viewholder.DoctorCommentHeaderViewHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorCommentViewHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorFunctionViewHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorHeaderViewHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorHomeDescriptViewHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorIngerRogationViewLLHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorOrderPayHolder;
import com.nf.health.app.inquiry.impl.viewholder.DoctorOrderServiceHolder;
import com.nf.health.app.models.DoctorCommnetVo;
import com.nf.health.app.widget.OnMyOnClistener;

import java.util.List;

/**
 *家庭服务，详细信息  adapter
 */
public class HomeServiceDescriptAdapter extends RecyclerView.Adapter implements View.OnClickListener{
    private int CPOUNT_ITEM_NUM = 0;
    private LayoutInflater inflater;
    private Activity cnt ;
    private DoctorOrderPayHolder.OnMyClickLintener onMyClickLintener;//注册点击事件

    public DoctorDetailBean docDetail;//获取医生详情基本信息
    public List<SubsDirect> subsDirectList;//获取医生的将健康评价
    public  DoctorOrderPayHolder doctorOrderPayHolder;
    public HomeServiceDescriptAdapter(Activity cnt, Object ss){
        inflater =LayoutInflater.from(cnt);
        this.cnt = cnt;
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if(viewType == DocType.TYPE_HEADER.getType()){
            View viewAds = inflater.inflate(R.layout.view_doctor_header_descript_view, null);// 医生基本详情 头像，简介
            return new DoctorHomeDescriptViewHolder(viewAds,cnt);
        }else if(viewType == DocType.TYPE_ORDER_SERVICE_LIST.getType()){
            View viewAds = inflater.inflate(R.layout.view_order_servide, null);// 医生所订购的服务列表
            return new DoctorOrderServiceHolder(viewAds,cnt);
        }/*else if(viewType == DocType.TYPE_ORDER_SERVICD_DATE  .getType()){
            View viewAds = inflater.inflate(R.layout.ll_view_service_price, null);// 医生所订购的服务日期
            return new DoctorOrderPayHolder(viewAds,cnt,onMyClickLintener);
        }*/
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if(holder instanceof DoctorHomeDescriptViewHolder){// 医生基本详情 头像，简介
            DoctorHomeDescriptViewHolder doctorHomeDescriptViewHolder = (DoctorHomeDescriptViewHolder) holder;
            doctorHomeDescriptViewHolder.loadData(docDetail);
        }else {//if(holder instanceof DoctorOrderServiceHolder) 医生基本详情 功能展示
            DoctorOrderServiceHolder doctorOrderServiceHolder = (DoctorOrderServiceHolder) holder;
            doctorOrderServiceHolder.loadData(subsDirectList.get(position - 1));
           //doctorOrderServiceHolder.reFreshMyTvText("250","150");
        }/*else  if(holder instanceof DoctorOrderPayHolder){
            doctorOrderPayHolder = (DoctorOrderPayHolder) holder;
            doctorOrderPayHolder.loadData(null);
        }*/
    }

    /**
     * 医生基本详情 头像，简介
     * @param docDetail
     */
    public void setMyHeaderDocDetail(DoctorDetailBean docDetail){
        this.docDetail = docDetail;
        notifyItemChanged(DocType.TYPE_HEADER.getType());
    }
    /**
     * 刷新功能（家庭服务，付费咨询，健康管理）
     * @param
     */
    public void setDocFunctionData(){
        notifyItemChanged(DocType.TYPE_FUNCTION.getType());
    }
    /**
     * 刷新功能 医生的评价
     * @param
     */
    public void setDoctorCommentData(  List<SubsDirect>  subsDirectList){
        this.subsDirectList =subsDirectList;
        notifyItemChanged(DocType.TYPE_ORDER_SERVICE_LIST.getType());
    }


    @Override
    public int getItemCount() {
        CPOUNT_ITEM_NUM = 1;
        if(subsDirectList != null ){
            CPOUNT_ITEM_NUM = CPOUNT_ITEM_NUM + subsDirectList.size();
        }
        return CPOUNT_ITEM_NUM;
    }
    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return  DocType.TYPE_HEADER.getType();
        } else   {
            return  DocType.TYPE_ORDER_SERVICE_LIST.getType();
        }
    }
    @Override
    public void onClick(View v) {

    }


    public void regisitOnClickListener(DoctorOrderPayHolder.OnMyClickLintener onMyClickLintener){
        this.onMyClickLintener = onMyClickLintener;
    }
}
